package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.OpenDoorRecord;
import com.macro.mall.dto.OpenDoorRecordRequest;
import com.macro.mall.service.OpenDoorRecordService;
import com.macro.mall.util.RequestData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author HuangZiy
 * @version 8.0
 * @date 2021/4/26 22:35
 */
@RestController
@RequestMapping(value = "/mms/storeOpenDoor")
public class OpenDoorController {

    @Autowired
    private OpenDoorRecordService openDoorRecordService;

    @GetMapping("/list")
    public CommonResult<List<OpenDoorRecord>> getOpenDoorRecord(@RequestData OpenDoorRecordRequest request) {
        return openDoorRecordService.getOpenDoorRecord(request);
    }


    @PostMapping
    public CommonResult<String> addOpenDoorRecord(@RequestBody OpenDoorRecordRequest request) {
        return openDoorRecordService.addOpenDoorRecord(request);
    }

    @PutMapping("/{id}")
    public CommonResult<String> updateOpenDoorRecord(@PathVariable Integer id, @RequestBody OpenDoorRecordRequest request) {
        return openDoorRecordService.updateOpenDoorRecord(request);
    }

    @DeleteMapping("/{id}")
    public CommonResult<String> deleteOpenDoorRecord(@PathVariable Integer id) {
        return openDoorRecordService.deleteOpenDoorRecord(id);
    }


}
